#include<sqlite3.h>
#include<stdio.h>
//-lsqlite3

int main()
{
    sqlite3 *db;
    int ret = sqlite3_open("test.db",&db);
    if(ret!=SQLITE_OK)
    {
        printf("open error:%s\n",sqlite3_errmsg(db));
    }

    char sql[400]={0};
    sprintf(sql,"select *from stu;");
    char **result;
    int row,column;
    if(sqlite3_get_table(db,sql,&result,&row,&column,NULL)!=SQLITE_OK)
    {
        printf("get table erroe:%s\n",sqlite3_errmsg(db));
    }
    printf("row:%d column:%d\n",row,column);

    for(int i=0;i<=row;i++)
    {
        for(int j=0;j<column;j++)
        {
            printf("%s|",result[i*column+j]);
        }
        printf("\n");
    }

    sqlite3_free_table(result);
    sqlite3_close(db);
    return 0;
}